<?php


global $mydb;
//connect();
//set_time_limit(999999999999);
 //test();
//die("X");
function connect(){
	global $mydb;
	$mydb = new wpdb('root','123','download.com.vn','localhost');
}

function test(){
	global $mydb;
	$rows = $mydb->get_results("select * from soft1 limit 20000");
	
	foreach ($rows as $obj) :
		$insert = array(
		  'post_title'           => $obj->SOFT_NAME, 
		  'post_content'           => $obj->SOFT_CONTENT, 
		  'post_status'           => 'publish', 
		  'post_type'             => 'soft',
		  'post_author'           => 1,
		  'ping_status'           => get_option('default_ping_status'), 
		  'post_parent'           => 0,
		  'menu_order'            => 0,
		  'to_ping'               =>  '',
		  'pinged'                => '',
		  'post_password'         => '',
		  'guid'                  => '',
		  'post_content_filtered' => '',
		  'post_excerpt'          => '',
		  'post_category' => array(1),
		  'import_id'             => 0
		);
		//wp_set_post_terms($post_id,$man,'manufacturer');
	$post_id =  wp_insert_post($insert);
	 add_post_meta($post_id, '_my_meta_value_key', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' , false);
	 
		 $man = array(9);
		//$t = wp_set_post_terms(29,$man,'manufacturer',true);
		global $wpdb;
		 
		$query = "INSERT INTO `pmn_term_relationships` (object_id, term_taxonomy_id) VALUES (".$post_id.", 6)"; 
           $wpdb->query($query);
		   $query = "INSERT INTO `pmn_term_relationships` (object_id, term_taxonomy_id) VALUES (".$post_id.", 2)"; 
            $wpdb->query($query);
		// $t = wp_set_post_terms(33,9,'post_tag',false);
		// $t = wp_set_post_terms(33,array(7),'manufacturer',false);
		 
	 
	 
 
	endforeach;
	
}








?>